package com.szdvte.news.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.szdvte.news.bean.NewsType;
import com.szdvte.news.dao.INewsTypeDao;

public class NewsTypeDaoImpl extends BaseDaoImpl implements INewsTypeDao {
	private boolean flag;
	@SuppressWarnings("unchecked")
	@Override
	public List<NewsType> select() {
		List<NewsType> list = new ArrayList<NewsType>();
		try {
			list = getSqlMapClient().queryForList("newsType.select");
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
	
	@Override
	public boolean add(NewsType newsType) {
		System.out.println(newsType.getNewsTypeName());
		flag = false;
		try {
			getSqlMapClient().insert("newsType.add",newsType);
			flag = true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public boolean delete(NewsType newsType) {
		flag = false;
		try {
			getSqlMapClient().update("newsType.delete",newsType);
			flag = true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public boolean update(NewsType newsType) {
		flag = false;
		try {
			getSqlMapClient().update("newsType.update",newsType);
			flag = true;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return flag;
	}

	@Override
	public NewsType load(NewsType newsType) {
		try {
			newsType = (NewsType) getSqlMapClient().queryForObject("newsType.load",newsType);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return newsType;
	}

}
